﻿
namespace Service
{
    using Data.Repository;
	using System.Collections.Generic;

    public class UserExtensionService : IUserExtensionService
    {
        private IUserExtensionRepository _userExtensionRepository;

        #region IUserExtensionService Members

        /// <summary>
        /// create new UserExtension
        /// </summary>
        /// <param name="theNewUserExtension">the new UserExtension instance</param>
        /// <returns>the new UserExtension's ID</returns>
        public int CreateNewUserExtension(Data.Entity.UserExtension theNewUserExtension)
        {
            if (theNewUserExtension == null)
            {
                return 0;
            }

            if (_userExtensionRepository == null)
            {
                _userExtensionRepository = new UserExtensionRepository();
            }

            return _userExtensionRepository.CreateNewUserExtension(theNewUserExtension);
        }

        #endregion

        #region IUserExtensionService Members


        public int UpdateUserExtension(Data.Entity.UserExtension theUserExtension)
        {
            if (theUserExtension == null || theUserExtension.UserID == null)
            {
                return 0;
            }

            if (_userExtensionRepository == null)
            {
                _userExtensionRepository = new UserExtensionRepository();
            }

            return _userExtensionRepository.UpdateUserExtension(theUserExtension);
        }

        public Data.Entity.UserExtension GetUserExtensionByUserID(System.Guid userID)
        {
            if (_userExtensionRepository == null)
            {
                _userExtensionRepository = new UserExtensionRepository();
            }

            return _userExtensionRepository.GetUserExtensionByUserID(userID);
        }

        #endregion
    }
}
